<template>
	<view class="recordlist">
		<view class="record-view" v-for="(item,index) in list" @click="urlClick(item.id)" v-if="list.length >0">
			<view>{{index+1}}、</view>
			<view class="record-view-cennet">{{item.questions.name}}</view>
			<view class="record-view-right">
				<text>{{item.time}}秒</text>
				<image src="../../static/icon/right.png"></image>
			</view>
		</view>
		
		<view class="notavailable" v-if="list.length ==0">
			<image src="../../static/zan.png"></image>
			<view>暂无数据</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bid  : '',
				cid  : '',
				page :1 ,
				limit : 20 ,
				list :[],
				count : 0,
			};
		},
		onLoad(e) {
			this.bid  = e.bid;
			this.cid  = e.cid;
			this.getall();
			console.log(e);
		},
		methods:{
			urlClick(e){
				uni.navigateTo({
					url:'/pages/record/details?id='+e
				})
			},
			getall(){
				let that  = this;
				that.$questions.getQuestionsuser({'bid':that.bid,'page':that.page,'limit':that.limit,'cid':that.cid}).then(res=>{
					that.list = [...that.list,...res.data.list];
					console.log(that.list.length)
					that.count= res.data.count;
				})
			}
		},
		onReachBottom(){
			this.page += 1;
			this.getall();
		},
		onPullDownRefresh() {
			this.page = 1;
			this.list= [];
			setTimeout(()=>{
				this.getall();
				uni.stopPullDownRefresh();
			},1000)
		},
	}
</script>

<style lang="less">
	page {
		width: 100%;
		height: 100%;
		background: #f6f9f8;
	}
	.recordlist {
		background-color: #fff;
		width: 100%;
		.record-view {
			width: 90%;
			margin: auto;
			display: flex;
			height: 120rpx;
			line-height: 120rpx;
			border-bottom: 2rpx solid #e3e3e3;
			font-size: 34rpx;
			.record-view-cennet {
				width: 460rpx;
			}
			.record-view-right {
				text-align: right;
				font-size: 28rpx;
				color: #999999;
				width: 180rpx;
				image {
					position: relative;
					top: 10rpx;
					width: 40rpx;
					height: 40rpx;
				}
			}
		}
		.record-view:last-child  {
			border: none ;
		}
	}
</style>
